<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="commons/head::myhead(~{::title},~{::link})">
    <title>siteadd</title>
    <!-- main CSS -->
    <link href="asserts/css/main.css" th:href="@{/asserts/css/main.css}" rel="stylesheet">
</head>
<body>
    <!--引入topbar-->
    <div th:replace="commons/bar::topbar"></div>
    <div class="container-fluid">
        <div class="row">
            <!--引入sidebar-->
            <div th:replace="commons/bar::#sidebar(activeUri='sitelist')"></div>
            <main role="main" class="col-md-10 ml-sm-auto col-lg-10 pt-3 px-4">
                <form action="commons/success.html" th:action="@{/main/site}" method="POST">
                    <!-- 修改用户发送PUT请求 -->
                    <!--
                    1、SpringMVC中配置HiddenHttpMethodFilter;（SpringBoot自动配置好的）
                    2、页面创建一个post表单
                    3、创建一个input项，name="_method";值就是我们指定的请求方式
                    -->
                    <input type="hidden" name="_method" value="PUT" th:if="${site!=null}"/>
                    <input type="hidden" name="id" th:if="${site!=null}" th:value="${site.id}"/>

                    <div class="form-group">
                        <label>[[#{site.name}]]</label>
                        <input class="form-control" name="name" type="text" placeholder="Sitename" th:placeholder="#{site.name}" th:value="${site!=null}?${site.name}"/>
                    </div>
                    <div class="form-group">
                        <label>[[#{site.longitude}]]</label>
                        <input class="form-control" name="coor.longitude" type="text" placeholder="Longitude" th:placeholder="#{site.longitude}" th:value="${site!=null}?${site.coor.longitude}"/>
                    </div>
                    <div class="form-group">
                        <label>[[#{site.latitude}]]</label>
                        <input class="form-control" name="coor.latitude" type="text" placeholder="Latitude" th:placeholder="#{site.latitude}" th:value="${site!=null}?${site.coor.latitude}"/>
                    </div>
					<div class="form-group">
						<label>[[#{site.type}]]</label>
						<select class="form-control" name="type">
							<option th:each="type:${types}" th:text="${type.value}" th:value="${type}" th:selected="${site!=null}?${type == site.type}">1</option>
						</select>
                    </div>
					<div class="form-group">
						<label>[[#{site.isfuel}]]</label>
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="isSource" value="1" th:checked="${site!=null}?${site.isSource==true}">
                            <label class="form-check-label" th:text="#{common.yes}">yes</label>
                        </div>
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="isSource" value="0" th:checked="${site!=null}?${site.isSource==false}">
                            <label class="form-check-label" th:text="#{common.no}">no</label>
                        </div>
					</div>
                    <button type="submit" class="btn btn-primary" th:text="${site!=null}?#{btn.update}:#{btn.add}">Submit</button>
                </form>
            </main>
        </div>
    </div>

    <div th:replace="commons/head::myscript(~{::script})">
        <script type="text/javascript"></script>
    </div>
</body>
</html>